<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div getTime="20" data-index="2" data-list-name="andy"></div>

    <script>
        var div = document.querySelector('div');
        //元素.dataset 获取是所有的data相关属性，放到一个对象中
        console.log(div.dataset);//DOMStringMap {index: "2", listName: "andy"}
        console.log(div.dataset.index);//2
        console.log(div.dataset['index']);//2
        console.log(div.dataset.listName);//andy
        console.log(div.dataset['listName']);//andy
    </script>
</body>
</html>